home *** CD-ROM | disk | FTP | other *** search
/ Merciful 4 / Merciful - Disc 4.iso / rexx / giftopng.pprx < prev    next >
Text File  |  1996-11-01  |  9KB  |  252 lines

  1. /* Personal Paint Amiga Rexx script - Copyright © 1995-1996 Cloanto Italia srl */
  2.  
  3. /* $VER: GifToPng.pprx 1.1 */
  4.  
  5. /** ENG
  6.   This script asks the user to specify a directory, scans the directory
  7.   and its subdirectories and converts all GIF files it finds into PNG.
  8.  
  9.   Non-GIF files are not affected. Icon images are preserved. Icon format
  10.   information is updated (Tool Types: FILETYPE=PNG). GIF Author, Copyright
  11.   and Comment fields are translated to PNG equivalents. File name suffixes
  12.   are changed (i.e. the files are renamed) as follows:
  13.  
  14.     .gif   -> .png
  15.     .GIF   -> .PNG
  16.     .Gif   -> .Png, etc.
  17.  
  18.     others -> unchanged
  19.  
  20.   Personal Paint identifies the file type by its contents (not by the file
  21.   name suffix). If the script runs during Workbench use, the Workbench Update
  22.   menu item must be selected to visually update the contents of any windows
  23.   containing files being renamed by this script.
  24.  
  25.   This script requires Personal Paint version 7.0 (PPaint Rexx version 7)
  26.   or higher, personal_png_io.library (enclosed with PPaint), and
  27.   personal_gif_io.library (or another GIF-compatible library).
  28.  
  29.  
  30.   Possible changes that could be applied to this file:
  31.  
  32.     Convert all images to PNG (not just GIFs). To do this, change the line
  33.     selecting GIFs to IF UPPER(RESULT) ~= 'PNG' THEN DO. However, be careful
  34.     if you have IFF animations, as they can be loaded as ILBM images unless
  35.     they are filtered out (IFF animations begin with an ILBM image).
  36.  
  37.     Activate PNG Adam 7 progressive display in files being written. This
  38.     degrades compression but the resulting images appear more nicely when
  39.     displayed by progressive viewers. Set PROGDSP=1.
  40.  
  41.     Convert any file to uncompressed IFF-ILBM. This may be good for files to
  42.     be stored on an Amiga CD-ROM, where loading speed could be more important
  43.     than compression. Remove the instructions selecting only GIFs and replace
  44.     the PNG FORMAT option with FORMAT ILBM OPTIONS "COMPR=0" "SCRFMT=0".
  45.  
  46.  
  47.   PNG was designed as a replacement and extension to GIF and LZW-based TIFF,
  48.   after Unisys Corporation began demanding royalties on GIF/LZW code. As
  49.   the PNG specification was released in May 1995, it gained general
  50.   recognition as the best lossless standard for storing digital images.
  51.  
  52.   Cloanto, the first software house to publish a paint program supporting the
  53.   PNG file format, is also making available a PNG developer's kit for the
  54.   Amiga (on the Personal Suite CD-ROM). A PNG DataType is available at no
  55.   cost for free electronic distribution.
  56. */
  57.  
  58. /** DEU
  59.   Die GIF-Bilder im angegebenen Verzeichnis (und in dessen
  60.   Unterverzeichnissen) lassen sich mit Hilfe dieses Skripts automatisch in
  61.   PNG-Bilder umwandeln.
  62.  
  63.   Nicht im GIF-Format vorliegende Bilder werden nicht berücksichtigt;
  64.   Icon-Dateien bleiben grundsätzlich unverändert, allerdings werden die
  65.   Formatinformationen der Formatänderung angepaßt (Merkmale: FILETYPE=PNG).
  66.   Außerdem die durch das GIF-Format unterstützten Felder für Autor,
  67.   Copyright und Kommentar ihren PNG-Äquivalenten angepaßt. Evtl. vorhandene
  68.   Dateinamenerweiterungen werden durch Umbenennung wie folgt geändert:
  69.  
  70.     .gif   -> .png
  71.     .GIF   -> .PNG
  72.     .Gif   -> .Png, usw.
  73.  
  74.     andere -> unverändert
  75.  
  76.   Personal Paint identifiziert das Dateiformat anhand des Dateiinhalts,
  77.   und nicht etwa anhand der Dateinamenerweiterung. Wenn dieses Skript
  78.   während der Benutzung der Workbench ausgeführt wird, muß zunächst
  79.   der Menübefehl "alles aktualisieren" im Menü "Workbench" ausgeführt werden,
  80.   um den Inhalt von Fenstern zu aktualisieren, die von diesem Skript
  81.   modifizierte Dateien enthalten.
  82.  
  83.   Dieses Skript erfordert Personal Paint 7.0 (PPaint Rexx Version 7)
  84.   oder höher, die personal_png_io.library (im Lieferumfang von PPaint
  85.   enthalten) und die personal_gif_io.library (oder eine andere
  86.   GIF-kompatible Library).
  87.  
  88.   Denkbare Änderungen an dieser Skriptdatei:
  89.  
  90.     Konvertierung sämtlicher Bilder (nicht nur GIF) in das PNG-Format.
  91.     Dazu ist die Zeile zur Auswahl der GIF-Bilder in
  92.     IF UPPER(RESULT) ~='PNG' THEN DO zu ändern. Hierbei ist im Hinblick
  93.     auf das Vorhandensein von Animationen im IFF-Format Vorsicht
  94.     walten zu lassen, da auch diese sich als ILBM-Bilder laden lassen
  95.     (IFF-Animationen beginnen mit einem ILBM-Bild).
  96.  
  97.     Aktivierung der "PNG Adam 7 progressive Display"-Option beim Speichern
  98.     der Dateien. Dies führt zwar zu einer verringerten Komprimierungsrate,
  99.     bewirkt aber bei der Anzeige mit einem geeigneten Programme eine
  100.     eine optimierte Darstellung. Set PROGDSP=1.
  101.  
  102.     Konvertierung einer beliebigen Grafikdatei in das umkomprimierte
  103.     IFF-ILBM-Format. Dies kann besonders für Dateien sinnvoll sein, die auf
  104.     einer speziell für den Amiga entwickelten CD-ROM gespeichert werden
  105.     sollen, und wenn die Ladegeschwindigkeit eine höhere Priorität genießt
  106.     als die Komprimierungsrate. Entfernen Sie einfach die Befehle, die
  107.     die Auswahl lediglich auf GIF-Bilder beschränken, und ersetzen Sie die
  108.     Option PNG FORMAT durch FORMAT ILBM OPTIONS "COMPR=0" "SCRFMT=0".
  109.  
  110.   Das PNG-Format wurde als Ersatz und Erweiterung zu GIF und dem
  111.   LZW-basierten TIFF-Format entwickelt, nachdem deren Eigentümer, die
  112.   Firma Unisys, für die Verwendung des GIF-/LZW-Codes Gebühren forderte.
  113.   Kurz nach der Veröffentlichung der PNG-Spezifikation im Mai 1995
  114.   genoß das Format bereits allgemeine Anerkennung als bester verlustfreier
  115.   Standard zur digitalen Bildspeicherung.
  116.  
  117.   Cloanto, die Entwickler des ersten Malprogramms mit PNG-Unterstützung,
  118.   sind auch die Herausgeber des PNG-Entwicklerpakets für den Amiga
  119.   (erhältlich auf der Personal Suite CD-ROM). Zusätzlich ist gratis ein
  120.   PNG-DataType erhältlich, der auf elektronischem Wege frei verteilt werden
  121.   darf.
  122. */
  123.  
  124. IF ARG(1, EXISTS) THEN
  125.     PARSE ARG PPPORT
  126. ELSE
  127.     PPPORT = 'PPAINT'
  128.  
  129. IF ~SHOW('P', PPPORT) THEN DO
  130.     IF EXISTS('PPaint:PPaint') THEN DO
  131.         ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
  132.         DO 30 WHILE ~SHOW('P',PPPORT)
  133.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  134.         END
  135.     END
  136.     ELSE DO
  137.         SAY "Personal Paint could not be loaded."
  138.         EXIT 10
  139.     END
  140. END
  141.  
  142. IF ~SHOW('P', PPPORT) THEN DO
  143.     SAY 'Personal Paint Rexx port could not be opened'
  144.     EXIT 10
  145. END
  146.  
  147. ADDRESS VALUE PPPORT
  148. OPTIONS RESULTS
  149. OPTIONS FAILAT 10000
  150.  
  151. Get 'LANG'
  152. IF RESULT = 1 THEN DO        /* Deutsch */
  153.     txt_req_sel       = 'GifToPng-Zielverzeichnis'
  154.     txt_err_svabort   = 'Speichervorgang wurde abgebrochen'
  155.     txt_err_ldabort   = 'Ladevorgang wurde abgebrochen'
  156.     txt_err_save      = 'Fehler beim Speichern: '
  157.     txt_err_load      = 'Fehler beim Laden: '
  158.     txt_err_oldclient = 'Für dieses Skript_ist eine neuere Version_von Personal Paint erforderlich'
  159. END
  160. ELSE IF RESULT = 2 THEN DO    /* Italiano */
  161.     txt_req_sel       = 'Selezionare cassetto'
  162.     txt_err_svabort   = 'Scrittura annullata'
  163.     txt_err_ldabort   = 'Lettura annullata'
  164.     txt_err_save      = 'Errore nella scrittura: '
  165.     txt_err_load      = 'Errore nella lettura: '
  166.     txt_err_oldclient = 'Questa procedura richiede_una versione più recente_di Personal Paint'
  167. END
  168. ELSE DO                /* English */
  169.     txt_req_sel       = 'GifToPng target directory'
  170.     txt_err_svabort   = 'User abort during save'
  171.     txt_err_ldabort   = 'User abort during load'
  172.     txt_err_save      = 'Error during save: '
  173.     txt_err_load      = 'Error during load: '
  174.     txt_err_oldclient = 'This script requires a newer_version of Personal Paint'
  175. END
  176.  
  177. Version 'REXX'
  178. IF RESULT < 7 THEN DO
  179.     RequestNotify 'PROMPT "'txt_err_oldclient'"'
  180.     EXIT 10
  181. END
  182.  
  183. LockGUI
  184. FreeBrush
  185. IF RC = 0 THEN
  186.     RequestPath '"'txt_req_sel'"'
  187. IF RC = 0 THEN DO
  188.     tmpfname = 'T:pprx_temp.'PRAGMA('ID')
  189.     ADDRESS COMMAND 'List >'tmpfname' 'RESULT' NOHEAD PAT=~(#?.info) LFORMAT="*"%s%s*"" ALL FILES'
  190.     IF OPEN('listfile', tmpfname, 'R') THEN DO
  191.         Get 'ICONS'
  192.         iconmode = RESULT
  193.         errcode = 0
  194.         Set '"ICONS=3"'
  195.         DO FOREVER
  196.             curfname = READLN('listfile')
  197.             IF EOF('listfile') THEN BREAK
  198.             GetFileFormat curfname
  199.             IF RC = 0 THEN DO
  200.                 IF UPPER(RESULT) = 'GIF' THEN DO
  201.                     LoadBrush curfname 'FORCE'
  202.                     IF RC = 0 THEN DO
  203.                         IF UPPER(RIGHT(curfname, 5)) = '.GIF"' THEN DO
  204.                             len = LENGTH(curfname)
  205.                             newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-3, 1)) + 9), curfname, len-3)
  206.                             newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-2, 1)) + 5), newfname, len-2)
  207.                             newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-1, 1)) + 1), newfname, len-1)
  208.                             IF EXISTS(SUBSTR(newfname,2,len-2)) = 0 THEN DO
  209.                                 ADDRESS COMMAND 'Rename >NIL: 'curfname' 'newfname
  210.                                 curiconfname = INSERT('.info', curfname, len-1)
  211.                                 newiconfname = INSERT('.info', newfname, len-1)
  212.                                 curfname = newfname
  213.                                 IF EXISTS(SUBSTR(curiconfname,2,len+3)) THEN DO
  214.                                     IF EXISTS(SUBSTR(newiconfname,2,len+3)) THEN
  215.                                         ADDRESS COMMAND 'Delete >NIL: 'curiconfname
  216.                                     ELSE
  217.                                         ADDRESS COMMAND 'Rename >NIL: 'curiconfname' 'newiconfname
  218.                                 END
  219.                             END
  220.                         END
  221.                         SaveBrush 'FORCE FILE 'curfname' FORMAT PNG OPTIONS "PROGDSP=0" "COMPR=6" "AUTO=1"'
  222.                         IF RC > 0 THEN DO
  223.                             errcode = RC
  224.                             IF RC = 5 THEN
  225.                                 errmess = txt_err_svabort
  226.                             ELSE
  227.                                 errmess = txt_err_save || RC
  228.                         END
  229.                         FreeBrush 'FORCE'
  230.                     END
  231.                     ELSE DO
  232.                         errcode = RC
  233.                         IF RC = 5 THEN
  234.                             errmess = txt_err_ldabort
  235.                         ELSE
  236.                             errmess = txt_err_load || RC
  237.                     END
  238.                 END
  239.             END
  240.             IF errcode > 0 THEN
  241.                 BREAK
  242.         END
  243.         IF errcode > 0 THEN
  244.             RequestNotify 'PROMPT "'errmess'"'
  245.  
  246.         Set '"ICONS='iconmode'"'
  247.         CALL CLOSE('listfile')
  248.     END
  249.     ADDRESS COMMAND 'Delete >NIL: 'tmpfname
  250. END
  251. UnlockGUI
  252.